﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

using CTRL;
using BLL;
using DAL;

namespace GUI_Client
{
    public partial class GUIMain : Form
    {
        private static GUIMain instance;

        private CtrlCar ctrlCar;
        private CtrlBooking ctrlBooking;

        public static Customer Customer { get; private set; }

        public GUIMain()
        {
            InitializeComponent();

            ctrlCar = CtrlCar.Instance;
            ctrlBooking = CtrlBooking.Instance;

            Customer = GUILogin.Customer;

            btnCars.Text = "Your cars: \r\n\r\n" + ctrlCar.GetAllCarsOwnedByCustomer(Customer.customerID).Count();
            btnBookings.Text = "Your bookings: \r\n\r\n" + ctrlBooking.GetAllBookingsOfCustomer(Customer.customerID).Count();
        }

        private void btnCars_Click(object sender, EventArgs e)
        {
            GUICars cars = GUICars.Instance;
            cars.Show();

            this.Hide();
        }

        private void btnLogout_Click(object sender, EventArgs e)
        {
            GUILogin login = GUILogin.Instance;
            login.Show();

            this.Hide();
        }

        private void btnBookings_Click(object sender, EventArgs e)
        {
            GUIBookings books = GUIBookings.Instance;
            books.Show();

            this.Hide();
        }

        private void btnNewBooking_Click(object sender, EventArgs e)
        {
            GUINewBooking books = GUINewBooking.Instance;
            books.Show();

            this.Hide();
        }

        public static GUIMain Instance
        {
            get
            {
                if (instance == null)
                    instance = new GUIMain();

                return instance;
            }
        }
    }
}